package com.huilian.iotbox.admin.wap.controller;
import com.huilian.iotbox.admin.wap.service.AppletOrOfficialAccountService;
import com.huilian.iotbox.data.common.ServerResponse;
import com.huilian.iotbox.data.dto.AppletOrOfficialAccountDto;
import com.huilian.iotbox.data.po.AppletOrOfficialAccount;
import com.huilian.iotbox.data.vo.UserInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * @author LinYinDong
 * @date 2024/6/29 上午10:44
 */
@Slf4j
@RestController
@RequestMapping("/api/appletOrOfficialAccount")
public class AppletOrOfficialAccountController extends UserInfoController {
    @Autowired
    private AppletOrOfficialAccountService appletOrOfficialAccountService;

    @PostMapping("/subscribeAuthorizeByAppId")
    public ServerResponse subscribeAuthorizeByAppId(@RequestBody AppletOrOfficialAccountDto appletOrOfficialAccountDto, HttpServletRequest request) {
        UserInfo userInfo = super.getLoginUserInfo(request);
        return appletOrOfficialAccountService.subscribeAuthorizeByAppId(appletOrOfficialAccountDto);
    }

    @GetMapping("/findAppletOrOfficialAccountRemarkName")
    public ServerResponse findAppletOrOfficialAccountRemarkName(HttpServletRequest request) {
        UserInfo userInfo = super.getLoginUserInfo(request);
        AppletOrOfficialAccountDto appletOrOfficialAccount = new AppletOrOfficialAccountDto();
        appletOrOfficialAccount.setUserInfo(userInfo);
        appletOrOfficialAccount.setUserId(userInfo.getId());
        return appletOrOfficialAccountService.findAppletOrOfficialAccountRemarkName(appletOrOfficialAccount);
    }
}
